package com.pajk.user.helper;

import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

public class AnyCertificateAcceptingTrustManagerFactory {

    private static final TrustManager DUMMY_TRUST_MANAGER = new X509TrustManager() {
                                                              @Override
                                                              public void checkClientTrusted(X509Certificate[] x509Certificates,
                                                                                             String s)
                                                                                                      throws CertificateException {
                                                                  // always trust
                                                              }

                                                              @Override
                                                              public void checkServerTrusted(X509Certificate[] x509Certificates,
                                                                                             String s)
                                                                                                      throws CertificateException {
                                                                  // always trust
                                                              }

                                                              @Override
                                                              public X509Certificate[] getAcceptedIssuers() {
                                                                  return new X509Certificate[0];
                                                              }
                                                          };

    public static TrustManager[] getTrustManagers() {
        return new TrustManager[] { DUMMY_TRUST_MANAGER };
    }
}
